package com.miyouke.chat;

import cn.hutool.core.date.DateUtil;

import java.io.File;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        String folderPath = "C:\\Users\\Administrator\\Desktop\\长江师范学院\\BOOT-INF\\classes\\com\\xlh\\"; // 替换为你要检查的文件夹路径

        Set<Long> creationDates = new HashSet<>();
        processFolder(folderPath, creationDates);

        System.out.println("文件夹中所有文件的创建日期：");
        for (Long creationDate : creationDates) {
            System.out.println(DateUtil.format(new Date(creationDate), "yyyy-MM-dd"));
        }
    }

    private static void processFolder(String folderPath, Set<Long> creationDates) {
        File folder = new File(folderPath);
        if (folder.exists() && folder.isDirectory()) {
            File[] files = folder.listFiles();
            if (files != null) {
                for (File file : files) {
                    if (file.isFile()) {
                        creationDates.add(file.lastModified());
                    } else if (file.isDirectory()) {
                        processFolder(file.getAbsolutePath(), creationDates);
                    }
                }
            }
        }
    }
}
